package test;
import static org.junit.Assert.*;
import expression.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

@SuppressWarnings("javadoc")
public class AdamWentzelIPTest
{
	@Before
	public void setUp() throws Exception
	{
	}

	@After
	public void tearDown() throws Exception
	{
	}

	/*
	 * Feel free to add comments if I made a mistake.
	 */
	@Test
	public void testInfixtoPostfixTranslator()
	{
		assertEquals("2 2 2 ^ ^ 2 / 2 / 5 * 5 * 10 + 5 + 5 - 10 - 0 + 0 -", InfixtoPostfixTranslator.eval("2 ^ 2 ^ 2 / 2 / 2 * 5 * 5 + 10 + 5 - 5 - 10 + 0 - 0"));
		assertEquals("100 200 * 20000 / 2 +", InfixtoPostfixTranslator.eval("100 * 200 / 20000 + 2"));
		assertEquals("1 4 2 / ^ 4 * 5 + 6 1 + -", InfixtoPostfixTranslator.eval("1 ^ ( 4 / 2 ) * 4 + 5 - ( 6 + 1 )")); // =2
		assertEquals("1 2 + 9 2 3 + 40 4 / * 3 ^ ^ / 2 -", InfixtoPostfixTranslator.eval("( ( 1 + 2 ) / 9 ^ ( ( 2 + 3 ) * ( 40 / 4 ) ) ^ 3 - 2 )")); // =-2
		assertEquals("2 2 ^ 2 2 ^ 2 2 2 / 2 2 * 2 * + 1 - * 2 2 2 ^ ^ / ^ ^", InfixtoPostfixTranslator.eval("( ( 2 ^ 2 ) ^ ( ( 2 ^ 2 ) ^ ( ( 2 * ( ( 2 / 2 ) + 2 * 2 * 2 - 1 ) ) / ( 2 ^ ( 2 ^ 2 ) ) ) ) )")); // =256
		assertEquals("61 61 * 61 * 7 9 * 2 - 3 ^ 1 + 5 + 6 - 3 / 3 * /", InfixtoPostfixTranslator.eval("( 61 * 61 * 61 / ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( 7 * 9 ) - 2 ) ^ 3 ) + 1 ) + 5 ) - 6 ) / 3 * 3 ) ) ) ) ) ) ) ) ) ) ) ) ) )")); // =3632.2915451895033
		assertEquals("2 3 1 + ^ 6 2 + 2 / 2 ^ /", InfixtoPostfixTranslator.eval("2 ^ ( 3 + 1 ) / ( ( ( 6 + 2 ) / 2 ) ^ 2 )")); // =1
	}
}
